//
//  YWGetNewsDataStatus.m
//  YueshengToutiao
//
//  Created by yellow on 2020/3/13.
//  Copyright © 2020 YW. All rights reserved.
//

#import "YWGetNewsDataStatus.h"

@implementation YWGetNewsDataStatus


-(NSString *)FileUrl{
    if ([_FileUrl isKindOfClass:[NSNull class]]|| _FileUrl == nil) {
        _FileUrl = @"";
    }
    return _FileUrl;
}

//-(NSNumber *)IsColumn{
//    if ([_IsColumn isKindOfClass:[NSNull class]] ) {
//        if ([_LabelName isKindOfClass:[NSNull class]] || _LabelName == nil || _LabelName.length == 0) {
//            _IsColumn = @(0);
//        }
//        else{
//            _IsColumn = @(1);
//        }
//
//            return _IsColumn;
//    }
//    else{
//        return _IsColumn;
//    }
//}


-(void)setNilValueForKey:(NSString *)key{
    
    
}

-(NSArray *)ArrImg{
    
    if ([_ArrImg isKindOfClass:[NSNull class]]||_ArrImg == nil) {
        _ArrImg = [NSArray array];
    }
    return _ArrImg;
    
}

-(YWCellType)cellType{
    
    if (self.ContentType.integerValue == 4) {
        
        if (self.VideoType.integerValue == 0) {
            return YWCellTypeVideo; //视频
        }
        else{
            return YWCellTypeLittleVideo; //小视频
        }
    }
    
    else{
        
        if (![self.Img isKindOfClass:[NSNull class]] && self.Img != nil && self.Img.length != 0) {
            
            return YWCellTypeOneImg; //有一张图片的文章
        }
        else{
            
            return YWCellTypeNoImg; //没有图片的文章
        }
    }
}

- (NSString *)AddDateTime
{
    // _created_at == Fri May 09 16:30:34 +0800 2014
    // 1.获得微博的发送时间
    NSDateFormatter *fmt = [[NSDateFormatter alloc] init];
    //    fmt.dateFormat = @"EEE MMM dd HH:mm:ss Z yyyy";
    fmt.dateFormat = @"yyyy-MM-dd HH:mm";
    
    
    //#warning 真机调试下, 必须加上这段
//    fmt.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];
    
//用这个时区
    [fmt setTimeZone:[NSTimeZone timeZoneWithName:@"Asia/Shanghai"]];
    
    NSLog(@"%@",_AddDateTime);
    
    NSDate *createdDate = [fmt dateFromString:_AddDateTime];
    
    // 2..判断微博发送时间 和 现在时间 的差距
    if (createdDate.isToday) { // 今天
        if (createdDate.deltaWithNow.hour >= 1) {
//            return [NSString stringWithFormat:@"%ld小时前", (long)createdDate.deltaWithNow.hour];
            
            fmt.dateFormat = @"今天 HH:mm";
            return [fmt stringFromDate:createdDate];
            
        } else if (createdDate.deltaWithNow.minute >= 1) {
            return [NSString stringWithFormat:@"%ld分钟前", (long)createdDate.deltaWithNow.minute];
        } else {
            return @"刚刚";
        }
    } else if (createdDate.isYesterday) { // 昨天
        fmt.dateFormat = @"昨天 HH:mm";
        return [fmt stringFromDate:createdDate];
    } else if (createdDate.isThisYear) { // 今年(至少是前天)
        fmt.dateFormat = @"MM-dd HH:mm";
        
        return [fmt stringFromDate:createdDate];
    } else { // 非今年
        fmt.dateFormat = @"yyyy-MM-dd";
        return [fmt stringFromDate:createdDate];
    }
}

MJCodingImplementation


@end
